<?php

class Test_Bootstrap extends Zend_Application_Module_Bootstrap
{

    protected function _initConfig()
    {

        // Controllers
        $GLOBALS['WSB']['controllers']['Test_ModelController'] = array(
            'mapperClass' => 'Test_Mapper',
            'columns' => array('id', 'username', 'firstname', 'lastname'),
            //'columns' = array('id', 'username', 'password', 'salutation', 'lastname', 'firstname', 'address', 'plz', 'location', 'country', 'phone1', 'phone2', 'fax', 'mobile', 'email', 'homepage', 'hidden', 'deleted', 'modified', 'created')
            'defSortField' => 'id',
            'defSortDirection' => 'desc',
            'translations' => array(
                WSB_MODULES_PATH . 'member/i18n/tables/feuser.%s.csv'
            )
        );

        // Mappers
        $GLOBALS['WSB']['mappers']['Test_Mapper'] = array(
            'collectionClass' => 'Test_Collection',
            'modelClass' => 'Test_Model',
            'filterSql' => implode(' LIKE ? OR ', array('id', 'username', 'password', 'salutation', 'lastname', 'firstname', 'address', 'plz', 'location', 'country', 'phone1', 'phone2', 'fax', 'mobile', 'email', 'homepage')),
            //'filterSql' => "MATCH (firstname) AGAINST (?)",
        );

        // Forms
        $GLOBALS['WSB']['forms']['Test_Model']['elements'] = array(
            'id' => array(
                'type' => 'hidden',
                'options' => array(
                    'label' => 'id'
                )
            ),
            'username' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'username',
                    'required' => true,
                    'validators' => array(
                        'uniqueFeuser' => 'feuserUsername'
                    )
                )
            ),
            'password' => array(
                'type' => 'password',
                'options' => array(
                    'label' => 'password',
                    'required' => empty($_POST['id']) ? true : false ,
                    'filters' => array(
                        //'md5' => 'md5'
                    )
                )
            ),
            'salutation' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'salutation'
                )
            ),
            'firstname' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'firstname',
                    'required' => true
                )
            ),
            'lastname' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'lastname',
                    'required' => true
                )
            ),
            'email' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'email',
                    'required' => true,
                    'validators' => array(
                        'email' => 'emailaddress'
                    )
                )
            ),
            'address' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'address'
                )
            ),
            'plz' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'plz'
                )
            ),
            'location' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'location'
                )
            ),
            'country' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'country'
                )
            ),
            'phone1' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'phone1'
                )
            ),
            'phone2' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'phone2'
                )
            ),
            'fax' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'fax'
                )
            ),
            'mobile' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'mobile'
                )
            ),
            'homepage' => array(
                'type' => 'text',
                'options' => array(
                    'label' => 'homepage'
                )
            ),
            'hidden' => array(
                'type' => 'checkbox',
                'options' => array(
                    'label' => 'hidden'
                )
            ),
            'members' => array(
                'type' => 'dbMultiSelect',
                'options' => array(
                    'label' => 'Member_Model_DbTable_Femember',
                    'unselectedSql' => 'SELECT id, name FROM fegroup WHERE deleted=0 ORDER BY name',
                    'selectedSql' => 'SELECT fegroup_id FROM femember WHERE feuser_id=?'
                )
            )
        );

        $elements = array_keys($GLOBALS['WSB']['forms']['Test_Model']['elements']);
        unset($elements[array_search('members', $elements)]);
        
        $GLOBALS['WSB']['forms']['Test_Model']['displayGroups'] = array(
            'account' => array(
                'elements' => $elements,
                'options' => array('legend' => 'Konto')
            ),
            'usergroups' => array(
                'elements' => array('members'),
                'options' => array('legend' => 'Members')
            )
        );

    }
    
}
